"""修改用户人脸信息"""
from datetime import datetime
from flask import g
import pytz



def add_experts_face_info(id_card, phone, face_pic, order_id):
    """添加专家人脸信息"""
    with g.db_conn.cursor() as cursor:
        current_timestamp = int(datetime.now(pytz.timezone('Asia/Shanghai')).timestamp())
        query = "UPDATE persons SET face_pic = %s, phone = %s, updated_at = %s, hk_visitor_order_id = %s WHERE id_card = %s AND deleted_at IS NULL RETURNING id"
        cursor.execute(query, (face_pic, phone, current_timestamp, order_id, id_card))
        g.db_conn.commit()


def update_experts_face_info(user_id, face_pic):
    """修改专家人脸信息"""
    with g.db_conn.cursor() as cursor:
        current_timestamp = int(datetime.now(pytz.timezone('Asia/Shanghai')).timestamp())
        base_query = "UPDATE persons SET face_pic = %s, updated_at = %s WHERE id_card = %s AND deleted_at IS NULL RETURNING id"
        cursor.execute(base_query, (face_pic, current_timestamp, user_id))
        g.db_conn.commit()
